package cn.lili.modules.order.order.client;

import cn.lili.modules.constant.ServiceConstant;
import cn.lili.modules.order.fallback.OrderItemFallback;
import cn.lili.modules.order.order.entity.dos.OrderItem;
import cn.lili.modules.order.order.entity.dto.OrderItemFlowSearchParams;
import cn.lili.modules.order.order.entity.enums.CommentStatusEnum;
import cn.lili.modules.order.order.entity.vo.OrderItemFlowUserVO;
import cn.lili.modules.order.order.entity.vo.OrderItemViewVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 子订单 client
 *
 * @author Chopper
 * @version v1.0 2021-11-08 09:52
 */
@FeignClient(path = "${server.servlet.context-path}", name = ServiceConstant.ORDER_SERVICE, contextId = "order-item", fallback = OrderItemFallback.class)
public interface OrderItemClient {

    /**
     * 子订单查询
     *
     * @param sn 子订单编号
     * @return 子订单
     */
    @GetMapping("/feign/orderitem/query/{sn}")
    OrderItem getBySn(@PathVariable String sn);

    /**
     * 子订单查询
     *
     * @param orderSn 订单编号
     * @param skuId   skuid
     * @return 子订单
     */
    @GetMapping("/feign/orderitem/query/order-sn-and-sku-id")
    OrderItem getByOrderSnAndSkuId(@RequestParam("orderSn") String orderSn, @RequestParam("skuId") String skuId);

    /**
     * 根据订单号查询子订单
     *
     * @param sn 订单编号
     * @return 子订单集合
     */
    @GetMapping("/feign/orderitem/query-by-order/{sn}")
    List<OrderItem> getByOrderSn(@PathVariable String sn);

    /**
     * 修改评论状态
     *
     * @param sn       订单编号
     * @param finished 评论状态
     */
    @GetMapping("/feign/orderitem/update/status")
    void updateCommentStatus(@RequestParam String sn, @RequestParam CommentStatusEnum finished);

    /**
     * 根据id修改模型
     *
     * @param orderItem 自订单
     */
    @PutMapping("/feign/orderitem/updateById")
    void updateById(@RequestBody OrderItem orderItem);

    @PostMapping("/feign/orderitem/save-batch")
    void saveBatch(@RequestBody List<OrderItem> orderItems);

    /**
     * 修改订单投诉状态
     *
     * @param orderItemIdList 获取订单货物ID
     * @return 是否操作成功
     */
    @PutMapping("/feign/order-item/update/complain")
    boolean updateComplainStatus(@RequestBody List<String> orderItemIdList);


    @PutMapping("/feign/orderitem/update")
    void update(@RequestBody OrderItem orderItem);

    /**
     * 根据查询参数获取子订单流水
     *
     * @param searchParams 查询参数
     * @return 子订单流水
     */
    @PostMapping("/feign/order/item/flow")
    Page<OrderItemFlowUserVO> getOrderFlowUserVOByCondition(@RequestBody OrderItemFlowSearchParams searchParams);

    /**
     * 根据查询参数获取分销金额总计
     *
     * @param searchParams 查询参数
     * @return 分销金额总计
     */
    @PostMapping("/feign/order/item/flow/amount")
    Long amountOderFlowUserVOByCondition(@RequestBody OrderItemFlowSearchParams searchParams);

    /**
     * 根据order_item_id_val查询订单
     * */
    @GetMapping("/feign/orderitem/get/val")
    OrderItem getByIdVal(@RequestParam String orderItemIdVal);

    /**
     * 查询店主的直推业绩,佣金收益总数
     */
    @PostMapping("/feign/order/getDistributionFlowPriceAndComissTotal")
    List<OrderItemViewVO> getDistributionFlowPriceAndComissTotal(@RequestBody List<String> memberIds);

    /**
     * 查询店主的直推业绩,佣金收益总数,本月
     */
    @PostMapping("/feign/order/getDistributionFlowPriceAndComissTotalCurrentMonth")
    List<OrderItemViewVO> getDistributionFlowPriceAndComissTotalCurrentMonth(@RequestBody List<String> memberIds);

    /**
     * 查询店主的直推业绩,佣金收益总数,上月
     */
    @PostMapping("/feign/order/getDistributionFlowPriceAndComissTotalLastMonth")
    List<OrderItemViewVO> getDistributionFlowPriceAndComissTotalLastMonth(@RequestBody List<String> memberIds);

    @PostMapping("/feign/order/getDistributionFlowPriceAndComissTotalDistribution")
    List<OrderItemViewVO> getDistributionFlowPriceAndComissTotalDistribution(@RequestBody List<String> memberIds);

    /**
     * 统计店主的业绩，订单数据
     * @param memberId
     * @param startTime
     * @param endTime
     * @return
     */
    @GetMapping("/feign/order/getDistributionFlowPriceAndComissTotalByMonth")
    OrderItemViewVO getDistributionFlowPriceAndComissTotalByMonth(@RequestParam String memberId, @RequestParam String startTime, @RequestParam String endTime);


    @PostMapping("/feign/order/getDistributionFlowPriceAndComissTotalType/{type}")
    List<OrderItemViewVO> getDistributionFlowPriceAndComissTotalType(@RequestBody List<String> memberIds, @PathVariable Integer type);

}
